package com.fanqiechaodan.composite;

/**
 * @author fanqiechaodan
 * @Classname Demo
 * @Description 组合模式
 */
public class Demo {

    public static void main(String[] args) {
        AbstractFile root = new Directory("根目录");

        AbstractFile file1 = new File("文件1");
        AbstractFile file2 = new File("文件2");
        AbstractFile file3 = new File("文件3");
        AbstractFile file4 = new File("文件4");

        AbstractFile directory1 = new Directory("目录1");
        AbstractFile directory2 = new Directory("目录2");

        directory1.add(file1);
        directory1.add(file2);
        directory1.add(directory2);

        directory2.add(file3);
        directory2.add(file4);

        root.add(directory1);
        root.display();
    }
}
